package cn.duotai.java;

public class Test {
    public static void main(String[] args) {
        Animal a =new Cat();
        Test t= new Test();
        a.eat();
        a.cry();
        t.test(a);

         a =new Dog();
        a.cry();
        a.eat();
        t.test(a);
        a= new Eagle();
        a.eat();
        a.cry();
        t.test(a);
    }

    private void test(Animal animal) {
        if(animal instanceof Cat){
            Cat cat= (Cat) animal;
            cat.catchMouse();
        }
        else if(animal instanceof Dog){
            Dog dog = (Dog) animal;
            dog.lookHouse();
        }
        else if(animal instanceof Eagle){
            Eagle eagle =(Eagle)animal;
            eagle.hunt();
        }
    }
}
